﻿<!--#include file="../inc/common.asp" -->
<!--#include file="waputil.asp" -->
<%
  response.contentType="text/vnd.wap.wml"
  'response.contentType="text/html"
  response.charset=DEFAULT_CHARSET
  response.buffer = true  

  'on error resume next
  call openDB

  if not userRightObj.canPost then
    message("您没有发布权限")
  end if

%>
<?xml version="1.0" encoding="<%=DEFAULT_CHARSET%>"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapfourm.org/DTD/wml_1.1.xml">
<wml>
<card title="编辑文章" newcontext="false" ordered="true">
<%
  dim content_id, title, detail, cat_id, is_secret
  if (request("actionType")="doSave") then
    title = filterHTML(request("title"))
    detail = filterHTML2(request("detail"), true)
    cat_id = request("_cat_id")
    if trim(cat_id)="" then
        cat_id = null
    else
        cat_id = clng(cat_id)    
    end if    
    is_secret = false
    if request("is_secret")="true" then
        is_secret = true
    end if
    if trim(title)="" then
      message("标题不能为空")
    end if
    if trim(detail)="" then
      message("内容不能为空")
    end if

    sql = " select blog_id, content_id,user_id, user_name, title,detail,more,excerpt,is_secret,start_date, end_date,insert_time,update_time,cat_id,show_content,face from blog_content where content_id=-1" 
    rs.open sql, conn, 1, 3
    rs.addNew()
    rs("blog_id") = blogObj.blogId
    rs("user_id") = userObj.userId
 	rs("user_name") =  userObj.userName
    rs("title") = title
    rs("detail") = detail
    rs("cat_id") = cat_id
    rs("is_secret") = is_secret
    rs("insert_time") = now()
    rs("start_date") = now()
    rs("end_date") = now()
    rs("update_time") = now()
    rs.update()
    content_id = rs("content_id")
    rs.close()
    
    call blogObj.loadTopItemsFromDB()
    call blogObj.cache()

    call blogCatObj.loadTotalItemCountFromDB()
    call blogCatObj.cache()
    
%>
<p>提交成功！<br/>
[<a href="detail.asp?blog_id=<%=blogObj.blogId%>&amp;content_id=<%=content_id%>">查看正文</a>]<br/>
[<a href="list.asp?blog_id=<%=blogObj.blogId%>">返回<%=HTML2WML(blogObj.blogTitle)%>首页</a>]<br/>
[<a href="list.asp">返回最新文章列表</a>]
</p>
<%        

  else
%>
<p align="left">
标题:<input name="v_title" title="文章标题" type="text" format="*M" emptyok="false" value="" />
内容:<input name="v_detail" title="文章内容" type="text" format="*M" emptyok="false" value="" />
分类:
<select name="v_cat_id" iname="v_cat_idx"  ivalue="1">
  <option value="">未分类</option>
<%
      sql = " select cat_id,  cat_name from blog_category  where blog_id=" & blogObj.blogId & " order by display_seq"
      rs.open sql, conn, 1, 1
      if not rs.eof then
        do until rs.eof
%>          
        <option value="<%=rs("cat_id")%>"  ><%=rs("cat_name")%></option>
<%
            rs.moveNext()
        loop
      end  if
      rs.close()
%>
</select>
是否公开:<select name="v_is_secret" iname="v_is_secret_idx"  ivalue="1">
        <option value="false">公开</option>
        <option value="true">保密</option>
</select>
</p>
<p align="center">
<anchor>[提交]<go href="edit.asp" method="post" accept-charset="<%=DEFAULT_CHARSET%>">
        <postfield name="actionType" value="doSave"/>
        <postfield name="blog_id" value="<%=blogObj.blogId%>"/>
        <postfield name="title" value="$v_title"/>
        <postfield name="detail" value="$v_detail"/>
        <postfield name="_cat_id" value="$v_cat_id"/>
        <postfield name="is_secret" value="$v_is_secret"/>
    </go></anchor>&nbsp;<anchor>[取消]<prev/></anchor>
</p>
<%
  end if
  writeBlogOptions
%>
</card>
</wml>